package app

import (
	"trader/apps/common"
	"trader/apps/note"
	"trader/apps/user"
	"trader/config"

	"github.com/gin-gonic/gin"
	"xorm.io/xorm"
)

func MountRouter(app *gin.Engine, engine *xorm.Engine, configInst *config.Config) {
	// 健康监测接口
	app.GET("/ping", func(ctx *gin.Context) {
		ctx.String(200, "pong")
	})

	// 通用模块
	common.Init(configInst.JWT)
	app.Use(common.CorsMiddleware())
	app.Use(common.DebugMiddleware())
	app.Use(common.JWTAuthMiddleware())

	// 用户模块
	userRoute := app.Group("/api/user")
	user.Init(userRoute, engine)

	// 笔记模块
	noteRoute := app.Group("/api/note")
	note.Init(noteRoute, engine)
}
